package cn.gxljc.technology.store_management.service.superadminservice.components.body;

import cn.gxljc.technology.store_management.entity.Ware;
import cn.gxljc.technology.store_management.mapper.WareMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Component
public class GoodsComponent {

    @Resource
    private WareMapper wareMapper;
    //增加商品成功0，不成功-1
    public Integer insertGoods(Ware goods){
        if (goods.getWareName()==null||goods.getWareType()==null){
            System.out.println("GoodsComponent/insertGoods/参数为空");
            return -1;
        }
        wareMapper.insertWare(goods);
        return 0;
    }

    //通过商品ID删除商品
    public Integer deleteGoods(String GoodsID){
        if(GoodsID !=null){
            deleteGoods(GoodsID);
        }else{
            System.out.println("删除失败");
        }

        System.out.println("删除成功");
        return null;
    }
    //
    public Ware findGoodsById(int GoodsID){
        //根据WareByID查询，如果不为空，返回wareMapper.selectWareByID(GoodsID)
        if(GoodsID == 0){
            System.out.println("GoodsComponent/findGoodsById/参数为空");
            return null;
        }
        wareMapper.selectWareByID(GoodsID);
        return wareMapper.selectWareByID(GoodsID);
    }

    //根据商品名findGoodsByName查询数据,如果有商品名输出list
    public List<Ware> findGoodsByName(String GoodsName){
        if (GoodsName == null){
            System.out.println("GoodsComponent/findGoodsByName/参数为空");
            return null;
        }
        wareMapper.selectWareByName(GoodsName);
        List<Ware> list=new ArrayList<Ware>();
        list.add(wareMapper.selectWareByName(GoodsName));
        return list;
    }

    //随机获取十条
    public List<Ware> findListGoods(Integer count){
        return null;
    }

    //给定范围获取对应的商品数
    public List<Ware> findListGoodsByLimit(Integer start,Integer end){

        return null;
    }

    //模糊查询商品
    public List<Ware> findGoodsByLetter(String letter){
        return null;
    }

    public List<Ware> findGoodsByType(String type){
        return null;
    }



}
